home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-07 | 2.5 KB | 86 lines | [TEXT/ALFA] |
- # FILE: update.tcl
- #
- # LAST UPDATE: 01/06/93 4:45:33 AM
- #
- # This file contains the following TCL procedure(s):
- #
- # update -- automatically updates timestamp on a file
- #
- #
- # Just add a line with 'LAST UPDATE: 01/2/34 5:67:89 AM' within the
- # first 500 characters of your file. Also add an alias of the form
- # {electricAlias def "" "UPDATE:" "UPDATE:§«update»"}. Now select the
- # space after the colon (:) and type DELETE TAB...you get a line similar
- # to: LAST UPDATE: 01/06/93 4:51:50 AM
- #
- # This proc is useful with electricAlias definitions (ie. §«update»).
- # In fact the date on THIS file is maintained thusly.
- #
- # To use, simply source this file place it in the a folder with the
- # name $HOME:Tcl:Usercode: and invoke it implicitly via the "unknown proc".
- #
- # SEE ALSO unknown.tcl, electricAlias.tcl
-
- # COPYRIGHT:
- #
- # Copyright © 1992,1993 by David C. Black
- # All rights reserved.
- #
- # Redistribution and use in source and binary forms are permitted
- # provided that the above copyright notice and this paragraph are
- # duplicated in all such forms and that any documentation,
- # advertising materials, and other materials related to such
- # distribution and use acknowledge that the software was developed
- # by David C. Black.
- #
- # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- #
- ################################################################################
-
- # AUTHOR
- #
- # David C. Black
- # Internet: black@mpd.tandem.com (preferred)
- # GEnie: D.C.Black
- # USnail: 6217 John Chisum Lane, Austin, TX 78749
- #
- ################################################################################
-
- # HISTORY
- #
- # modified who rev reason
- # -------- --- --- ------
- # 01/06/93 DCB 1.0 Original
-
- proc update {args} {
- set max [maxPos]
- if {$max > 500} {
- set max 500
- }
- set pos [getPos]
- set end [selEnd]
- set text [getText 0 $max]
- set hour {[0-9][0-9]?:[0-9][0-9]:[0-9][0-9] [AP]M}
- set date {[0-9][0-9]?/[0-9][0-9]?/[0-9][0-9]}
- set patt "LAST UPDATE ?: ( *$date $hour)"
- if {![regexp -indices $patt $text all datePos]} {
- return ""
- }
- set p1 [lindex $datePos 0]
- set p2 [expr {[lindex $datePos 1]+1}]
- set text [getText $p1 $p2]
- set time [mtime [now] short]
- if {$text == $time} {
- return ""
- }
- replaceText $p1 $p2 $time
- goto $pos
- select $pos $end
- return ""
- }
- #endproc update
- ################################################################################
-
-